package com.kafka.demo.service;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Service;

@Service
@Slf4j
@Data
@ConfigurationProperties("app.topic")
public class KafkaSender {

    @Autowired
    private KafkaTemplate<String,Object> kafkaTemplate;

    private String kafkatest;

    public void send(String message){
        log.info("sending message={} to topic={}", message, kafkatest);
        kafkaTemplate.send(kafkatest,message);
    }

}
